import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { storageGet, storageSet } from '@/utils'
export const useCounterStore = defineStore('counter', () => {
    const count = ref(0)
    const doubleCount = computed(() => count.value * 2)
    function increment(){
        count.value++
    }

    return { count, doubleCount, increment }
})
//系统管理
export const sysStore = defineStore('sysStore', () => {
    //标题
    const title = ref('')//
    const setTitle = (val) => {
        title.value = val
    }
    //省份
    const province = ref('')
    const setProvince = (val) => {
        province.value = val
    }
    return { title, setTitle, province, setProvince }
})

//
export const mainStore = defineStore('mainStore', () => {
    //面包屑
    const breadData = ref([])//
    const setBread = (val) => {
        breadData.value = val
    }
    return { breadData, setBread }
})

//首页
export const homeStore = defineStore('homeStore', () => {
    const nowCity = ref({})//当前城市
    const setNowCity = (val) => {
        nowCity.value = val
    }
    return { nowCity, setNowCity }
})

//菜单
export const muenStore = defineStore('muenStore', () => {
    const baseMenu = ref([])//
    const nowMenu = ref('')
    nowMenu.value = storageGet('nowMenu') || '工作台'
    baseMenu.value = storageGet('baseMenu') || []
    const setMenu = (val) => {
        storageSet('nowMenu', val)
        nowMenu.value = val
    }
    const setBaseMenu = (val) => {
        storageSet('baseMenu', val)
        baseMenu.value = val
    }
    return { baseMenu, nowMenu, setMenu, setBaseMenu }
})